<?php
$db = new Database();
if(isset($_POST['action'])){
    if($_POST['action']=="login"){
        $username = $_POST['username'];
        $password = $_POST['password'];
        $session = new Auth();
        
        $login = $session->login($username,$password,'username','password','tbuser');
        $id = $login['id'];
        if($login)
        {
            echo "Yes";
            $set = array("online"=>1);
            $con = array("id"=>$id);
            $db->update("tbuser",$set,$con);
        }else{
            echo "no";
        }
    }elseif($_POST['action']=="getimage"){
        $value = $_POST['value'];
        $getImage = $db->query("SELECT * FROM tbuser WHERE username='$value'","row");
        $count = $db->query("SELECT * FROM tbuser WHERE username='$value'","numrows");
        if($getImage['extension']){
            echo "/images/avatar/".$getImage['id']."/1/yourAvatar_".$getImage['id'].".".$getImage['extension'];
        }else{
            echo "No Record Found.";
        }
        
    }
}

?>